import request from '@/utils/request'

// 资产对象

// 删除资产对象信息
export function delAsset (params) {
  var data = fromData(params)
  return request({
    url: '/asset_object/del_asset',
    method: 'post',
    data
  })
}

// 增加资产对象信息
export function addAsset (params) {
  var data = fromData(params)
  return request({
    url: '/asset_object/addAsset',
    method: 'post',
    data
  })
}

// 编辑资产对象信息
export function editAsset (params) {
  var data = fromData(params)
  return request({
    url: '/asset_object/editAsset',
    method: 'post',
    data
  })
}

// 获取资产对象信息
export function getAssetInfo (params) {
  var data = fromData(params)
  return request({
    url: '/asset_object/getAssetInfo',
    method: 'post',
    data
  })
}

// 获取资产对象列表
export function getAssetArray (params) {
  var data = fromData(params)
  return request({
    url: '/asset_object/getAssetArray',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
